﻿@using Service.Infrastructure.Model
@{
    ViewBag.Title = "异常日志";
    var list = (List<ExceptionLogModel>)TempData["Data"];
}
@section HeadPlugin{
    <link href="~/Content/timeline.css" type="text/css" rel="stylesheet">
}
<div class="col-md-12">
    <ul class="timeline">
        @if (list.Count == 0)
        {
            <li class="timeline-green">
                <div class="timeline-time">
                    <span class="date">
                        @DateTime.Now.ToShortDateString()
                    </span>
                    <span class="time">
                        @DateTime.Now.ToShortTimeString()
                    </span>
                </div>
                <div class="timeline-icon">
                    <i class="fa fa-trophy"></i>
                </div>
                <div class="timeline-body">
                    <h2>Everthing be alright ^_^</h2>
                    <div class="timeline-content">
                        平台运行到现在一切正常
                    </div>
                </div>
            </li>
        }
        @foreach (var obj in list)
        {
            <li class="timeline-grey">
                <div class="timeline-time">
                    <span class="date">
                        @obj.Date
                    </span>
                    <span class="time">
                        @obj.Time
                    </span>
                </div>
                <div class="timeline-icon " onclick="del('@obj.Id',this)">
                    <i class="fa fa-times "></i>
                </div>
                <div class="timeline-body">

                    <a href="#" class="nav-link pull-right" onclick="showMsg(this);">
                        Read more <i class="m-icon-swapright m-icon-white"></i>
                    </a>

                    <h2>Runtime Exception-  </h2><h5>@obj.Title</h5>

                    <div class="timeline-content" style="display: none">
                        @obj.Content
                    </div>

                </div>
            </li>
        }

    </ul>
</div>

@section FootPlugin{
    <script type="text/javascript">
        //处理异常，处理后不再显示
        function del(id, obj) {

            $.ajax({
                url: '@Url.Action("HandleException","Admin")',
                type: 'POST',
                data: {
                    id: id
                },
            }
            ).done(function (data) {
                if (data.ReCode == 3002) {
                    $(obj).parent().hide();
                }
            });

        }

        //显示或隐藏异常内容
        function showMsg(obj) {
            $(".timeline-content").hide("slow");
            //切换状态
            var d = $(obj).siblings().filter(".timeline-content");
            if (d.is(":hidden")) {
                d.show("slow");
            } else {
                d.hide("slow");
            }

        }
    </script>
}
